package c.e.a.b.f.b;

import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import c.e.a.b.b.j.c;
import com.huawei.hms.jos.games.ranking.RankingConst;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
public final class h7 extends a5 {
    public volatile i7 c;
    public i7 d;
    public i7 e;
    public final Map<Activity, i7> f = new ConcurrentHashMap();
    public Activity g;
    public volatile boolean h;
    public volatile i7 i;
    public i7 j;
    public boolean k;
    public final Object l = new Object();
    public String m;

    public h7(u4 u4Var) {
        super(u4Var);
    }

    public static void A(i7 i7Var, Bundle bundle, boolean z) {
        String str = "_si";
        String str2 = "_sn";
        String str3 = "_sc";
        if (i7Var == null || (bundle.containsKey(str3) && !z)) {
            if (i7Var == null && z) {
                bundle.remove(str2);
                bundle.remove(str3);
                bundle.remove(str);
            }
            return;
        }
        String str4 = i7Var.a;
        if (str4 != null) {
            bundle.putString(str2, str4);
        } else {
            bundle.remove(str2);
        }
        str4 = i7Var.b;
        if (str4 != null) {
            bundle.putString(str3, str4);
        } else {
            bundle.remove(str3);
        }
        bundle.putLong(str, i7Var.c);
    }

    public static String x(String str) {
        String[] split = str.split("\\.");
        str = split.length > 0 ? split[split.length - 1] : "";
        return str.length() > 100 ? str.substring(0, 100) : str;
    }

    /* JADX WARNING: Removed duplicated region for block: B:67:0x0131  */
    /* JADX WARNING: Removed duplicated region for block: B:60:0x010d  */
    public final void B(c.e.a.b.f.b.i7 r9, c.e.a.b.f.b.i7 r10, long r11, boolean r13, android.os.Bundle r14) {
        /*
        r8 = this;
        r8.g();
        r0 = r8.a;
        r0 = r0.g;
        r1 = c.e.a.b.f.b.p.T;
        r0 = r0.o(r1);
        r1 = 1;
        r2 = 0;
        if (r0 == 0) goto L_0x0022;
    L_0x0011:
        if (r13 == 0) goto L_0x0019;
    L_0x0013:
        r13 = r8.e;
        if (r13 == 0) goto L_0x0019;
    L_0x0017:
        r13 = 1;
        goto L_0x001a;
    L_0x0019:
        r13 = 0;
    L_0x001a:
        if (r13 == 0) goto L_0x002c;
    L_0x001c:
        r0 = r8.e;
        r8.C(r0, r1, r11);
        goto L_0x002c;
    L_0x0022:
        if (r13 == 0) goto L_0x002b;
    L_0x0024:
        r13 = r8.e;
        if (r13 == 0) goto L_0x002b;
    L_0x0028:
        r8.C(r13, r1, r11);
    L_0x002b:
        r13 = 0;
    L_0x002c:
        if (r10 == 0) goto L_0x004a;
    L_0x002e:
        r3 = r10.c;
        r5 = r9.c;
        r0 = (r3 > r5 ? 1 : (r3 == r5 ? 0 : -1));
        if (r0 != 0) goto L_0x004a;
    L_0x0036:
        r0 = r10.b;
        r3 = r9.b;
        r0 = c.e.a.b.f.b.t9.q0(r0, r3);
        if (r0 == 0) goto L_0x004a;
    L_0x0040:
        r0 = r10.a;
        r3 = r9.a;
        r0 = c.e.a.b.f.b.t9.q0(r0, r3);
        if (r0 != 0) goto L_0x004b;
    L_0x004a:
        r2 = 1;
    L_0x004b:
        if (r2 == 0) goto L_0x014a;
    L_0x004d:
        r0 = new android.os.Bundle;
        r0.<init>();
        r2 = r8.a;
        r2 = r2.g;
        r3 = c.e.a.b.f.b.p.v0;
        r2 = r2.o(r3);
        if (r2 == 0) goto L_0x006b;
    L_0x005e:
        if (r14 == 0) goto L_0x0066;
    L_0x0060:
        r0 = new android.os.Bundle;
        r0.<init>(r14);
        goto L_0x006b;
    L_0x0066:
        r0 = new android.os.Bundle;
        r0.<init>();
    L_0x006b:
        r7 = r0;
        A(r9, r7, r1);
        if (r10 == 0) goto L_0x008a;
    L_0x0071:
        r14 = r10.a;
        if (r14 == 0) goto L_0x007a;
    L_0x0075:
        r0 = "_pn";
        r7.putString(r0, r14);
    L_0x007a:
        r14 = r10.b;
        if (r14 == 0) goto L_0x0083;
    L_0x007e:
        r0 = "_pc";
        r7.putString(r0, r14);
    L_0x0083:
        r0 = r10.c;
        r10 = "_pi";
        r7.putLong(r10, r0);
    L_0x008a:
        r10 = r8.a;
        r10 = r10.g;
        r14 = c.e.a.b.f.b.p.T;
        r10 = r10.o(r14);
        r0 = 0;
        if (r10 == 0) goto L_0x00d6;
    L_0x0098:
        if (r13 == 0) goto L_0x00d6;
    L_0x009a:
        r10 = c.e.a.b.e.c.u9.b;
        r10 = r10.q();
        r10 = (c.e.a.b.e.c.x9) r10;
        r10 = r10.q();
        if (r10 == 0) goto L_0x00c1;
    L_0x00a8:
        r10 = r8.a;
        r10 = r10.g;
        r13 = c.e.a.b.f.b.p.V;
        r10 = r10.o(r13);
        if (r10 == 0) goto L_0x00c1;
    L_0x00b4:
        r10 = r8.s();
        r10 = r10.e;
        r13 = r10.b;
        r13 = r11 - r13;
        r10.b = r11;
        goto L_0x00cb;
    L_0x00c1:
        r10 = r8.s();
        r10 = r10.e;
        r13 = r10.b();
    L_0x00cb:
        r10 = (r13 > r0 ? 1 : (r13 == r0 ? 0 : -1));
        if (r10 <= 0) goto L_0x00d6;
    L_0x00cf:
        r10 = r8.k();
        r10.G(r7, r13);
    L_0x00d6:
        r10 = r8.a;
        r10 = r10.g;
        r11 = c.e.a.b.f.b.p.v0;
        r10 = r10.o(r11);
        if (r10 == 0) goto L_0x00fe;
    L_0x00e2:
        r10 = r8.a;
        r10 = r10.g;
        r10 = r10.z();
        r10 = r10.booleanValue();
        if (r10 != 0) goto L_0x00f7;
    L_0x00f0:
        r10 = 1;
        r12 = "_mst";
        r7.putLong(r12, r10);
    L_0x00f7:
        r10 = r9.e;
        if (r10 == 0) goto L_0x00fe;
    L_0x00fb:
        r10 = "app";
        goto L_0x0100;
    L_0x00fe:
        r10 = "auto";
    L_0x0100:
        r3 = r10;
        r10 = r8.a;
        r10 = r10.g;
        r11 = c.e.a.b.f.b.p.v0;
        r10 = r10.o(r11);
        if (r10 == 0) goto L_0x0131;
    L_0x010d:
        r10 = r8.a;
        r10 = r10.n;
        r10 = (c.e.a.b.b.j.c) r10;
        java.util.Objects.requireNonNull(r10);
        r10 = java.lang.System.currentTimeMillis();
        r12 = r9.e;
        if (r12 == 0) goto L_0x0126;
    L_0x011e:
        r12 = r9.f;
        r14 = (r12 > r0 ? 1 : (r12 == r0 ? 0 : -1));
        if (r14 == 0) goto L_0x0126;
    L_0x0124:
        r5 = r12;
        goto L_0x0127;
    L_0x0126:
        r5 = r10;
    L_0x0127:
        r2 = r8.n();
        r4 = "_vs";
        r2.E(r3, r4, r5, r7);
        goto L_0x014a;
    L_0x0131:
        r2 = r8.n();
        r2.g();
        r10 = r2.a;
        r10 = r10.n;
        r10 = (c.e.a.b.b.j.c) r10;
        java.util.Objects.requireNonNull(r10);
        r5 = java.lang.System.currentTimeMillis();
        r4 = "_vs";
        r2.E(r3, r4, r5, r7);
    L_0x014a:
        r8.e = r9;
        r10 = r8.a;
        r10 = r10.g;
        r11 = c.e.a.b.f.b.p.v0;
        r10 = r10.o(r11);
        if (r10 == 0) goto L_0x015e;
    L_0x0158:
        r10 = r9.e;
        if (r10 == 0) goto L_0x015e;
    L_0x015c:
        r8.j = r9;
    L_0x015e:
        r10 = r8.p();
        r10.g();
        r10.t();
        r11 = new c.e.a.b.f.b.w7;
        r11.m1511init(r10, r9);
        r10.z(r11);
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.h7.B(c.e.a.b.f.b.i7, c.e.a.b.f.b.i7, long, boolean, android.os.Bundle):void");
    }

    public final void C(i7 i7Var, boolean z, long j) {
        a m = m();
        Objects.requireNonNull((c) this.a.n);
        m.t(SystemClock.elapsedRealtime());
        boolean z2 = i7Var != null && i7Var.d;
        if (s().w(z2, z, j) && i7Var != null) {
            i7Var.d = false;
        }
    }

    public final void D(String str, i7 i7Var) {
        g();
        synchronized (this) {
            String str2 = this.m;
            if (str2 == null || str2.equals(str)) {
                this.m = str;
            }
        }
    }

    public final i7 E(Activity activity) {
        Objects.requireNonNull(activity, "null reference");
        i7 i7Var = (i7) this.f.get(activity);
        if (i7Var == null) {
            i7 i7Var2 = new i7(null, x(activity.getClass().getCanonicalName()), k().t0());
            this.f.put(activity, i7Var2);
            i7Var = i7Var2;
        }
        return (this.a.g.o(p.v0) && this.i != null) ? this.i : i7Var;
    }

    public final boolean v() {
        return false;
    }

    public final i7 w(boolean z) {
        t();
        g();
        if (!this.a.g.o(p.v0) || !z) {
            return this.e;
        }
        i7 i7Var = this.e;
        return i7Var != null ? i7Var : this.j;
    }

    public final void y(Activity activity, Bundle bundle) {
        if (this.a.g.z().booleanValue() && bundle != null) {
            bundle = bundle.getBundle("com.google.app_measurement.screen_service");
            if (bundle != null) {
                this.f.put(activity, new i7(bundle.getString(RankingConst.RANKING_JGW_NAME), bundle.getString("referrer_name"), bundle.getLong("id")));
            }
        }
    }

    public final void z(Activity activity, i7 i7Var, boolean z) {
        i7 i7Var2;
        i7 i7Var3 = i7Var;
        i7 i7Var4 = this.c == null ? this.d : this.c;
        if (i7Var3.b == null) {
            i7Var2 = new i7(i7Var3.a, activity != null ? x(activity.getClass().getCanonicalName()) : null, i7Var3.c, i7Var3.e, i7Var3.f);
        } else {
            i7Var2 = i7Var3;
        }
        this.d = this.c;
        this.c = i7Var2;
        Objects.requireNonNull((c) this.a.n);
        a().v(new j7(this, i7Var2, i7Var4, SystemClock.elapsedRealtime(), z));
    }
}
